package scottb.flex;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;

public class FlexGradient {

    private List<Color> colors = new ArrayList<Color>();
    private List<Float> fractions = new ArrayList<Float>();

    public FlexGradient() {

    }
    public FlexGradient(int color1, int color2) {
        this(new Color(color1), new Color(color2));
    }

    public FlexGradient(Color color1, Color color2) {
        this(color1, 0, color2, 1);
    }

    public FlexGradient(Color color1, float fraction1, Color color2, float fraction2) {

        add(color1, fraction1);
        add(color2, fraction2);
    }

    public void add(Color color, float fraction) {
        colors.add(color);
        fractions.add(fraction);
    }

    public Color[] getColors() {
        return colors.toArray(new Color[0]);
    }

    public float[] getFractions() {
        float[] array = new float[fractions.size()];

        for(int x=0; x<array.length; x++) {
            array[x] = fractions.get(x);
        }

        return array;
    }
}
